import club.banyuan.Class;
import club.banyuan.Student;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

public class StuTest {
    Student student1 = new Student(1, "张三", 18);
    Student student2 = new Student(53, "李四", 22);
    Student student3 = new Student(33, "王五", 15);
    Student student4 = new Student(14, "赵六", 28);

    Student student5 = new Student(1, "A", 24);


    @Test
    public void setTest() {
        Class class1 = new Class();
        class1.getStudents().add(student1);
        class1.getStudents().add(student5);
        class1.printInfo();
        Assert.assertEquals(1, class1.getStudents().size());
    }

    @Test
    public void addMultipleDataTest() {

        Student[] students = getStudents();

        Class class1 = new Class();
        class1.addMultipleData(students);
        class1.printInfo();
        Assert.assertEquals(students.length, class1.getStudents().size());

    }

    @Test
    public void sortAscendingByIdTest() {
        Student[] students = getStudents();

        Class class1 = new Class();
        class1.addMultipleData(students);
        class1.sortAscendingById();
        System.out.println(class1.sortAscendingById());
        Assert.assertEquals(student2, class1.sortAscendingById().get(3));


    }

    @Test
    public void sortDescendingByAgeTest() {
        Student[] students = getStudents();

        Class class1 = new Class();
        class1.addMultipleData(students);

        class1.sortDescendingByAge();
        System.out.println(class1.sortDescendingByAge());
        Assert.assertEquals(student3, class1.sortDescendingByAge().get(3));
    }

    private Student[] getStudents() {
        Student[] students = new Student[4];
        students[0] = student1;
        students[1] = student2;
        students[2] = student3;
        students[3] = student4;
        return students;
    }

}
